<template>
  <div class="publicBox" id="shoperCss">
    <div class="boxItem" id="publicSearch">      

<el-form ref="form" :inline="true"  class="demo-form-inline">
    <el-row>
  <el-form-item label="交易流水号">
            <el-input class="pubIpt" v-model="ruleForm.no"  placeholder="请输入交易流水号"></el-input>
  </el-form-item>
    <el-form-item label="交易时间"  class="pubSltL label_right">
        <el-date-picker
        v-model="ruleForm.createTime"
        type="date"
        placeholder="选择日期">
        </el-date-picker>
  </el-form-item>
  <el-form-item label="订单状态" :required="false" class="label_right" >
  <el-select v-model="ruleForm.status" filterable  placeholder="全部" class="pubSlt138">
    <el-option
      v-for="item in orderStatus"
      :key="item.id"
      :label="item.name"
      :value="item.id" 
      >
    </el-option>
  </el-select>
  </el-form-item>
 <el-form-item class="label_btn">
            <el-button class="pubBtnBlue" @click="init" type="primary">查询</el-button>
            <el-button class="pubBtnBlue" type="primary" @click="exportFn">导出</el-button>
  </el-form-item>
    </el-row>

</el-form>
</div>
          
          <public-table  
          @handleEdit="handleEdit" 
          :columnDefs="columnDefs" 
          @changePage="changePage"
          :btn="['see']"
          :tableData="tableData"></public-table>
  </div>
</template>

<script>
import publicTable from "@/components/public/publicTable.vue"
import * as API from '@api/orders.js'
import * as pubAPI from '@api/public.js'
import  baseConfig from '@api/common/baseconfig.js'
export default {
  components: {
         publicTable
  },
  data() {
    return {
          ruleForm:{
           page:1,
           size:100,
           no:null,
           createTime:null,
           status:null
        }, 
        orderStatus:[
             {id:null,name:"全部"},
             {id:2,name:"退款完成"},
             {id:3,name:"审核中"},
             {id:4,name:"退款中"},
        ],
        columnDefs :[
            {headerName: '交易时间', field: 'createtime',width:175},
            {headerName: '交易流水号', field: 'no',width:208},
            {headerName: '订单编号', field: 'orderno',width:265},
            {headerName: '订单金额', field: 'orderamount',width:100},
            {headerName: '优惠金额', field: 'discountamount',width:100},
            {headerName: '支付金额', field: 'payamount',width:100},
            {headerName: '支付方式', field: 'typename',width:100},
            {headerName: '状态', field: 'orderpaystatusname',width:100},
        ],
        tableData: [],
    }
  },
  // 计算属性，会监听依赖属性值随之变化
  computed: {


  },
  // 监控data中的数据变化
  watch: {


 },
  methods: {
        async exportFn(){
        await API.exprotFinance(this.ruleForm,baseConfig.baseUrl).then(res=>{
              pubAPI.creatExcelFn("支付订单管理.xlsx",res)
        })
    },
    changePage(pageSize,pageNum){
          this.pageSize=pageSize;this.pageNum=pageNum
          this.init()
    },
    init(){
          if(this.ruleForm.createTime!=null)this.ruleForm.createTime=this.ChangeDateFormat(this.ruleForm.createTime)
          API.getFinance(this.ruleForm).then(res=>{
               if(res.IsPositive){
                  this.tableData=res.Data
               }else{
                  this.$message.error({message:res.ErrorCode})
               }
          })

    },   
    handleEdit(row){
      this.$router.push({path:"/platform/finance/pay_orderedit",query:{data:JSON.stringify(row)}})
    }

  },
  created() {
        this.init()
  },
  mounted() {


  },
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {}, // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>

<style lang='less' scoped>
@import "../../styles/less/public.less";
  #shoperCss{
    .boxItem{
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: center;
      .demo-form-inline{
        align-items: center;
      }
      .itemp{
      font-size: 16px;
      } 
      .label_right{
            margin-left: 28px;
        }
        .label_btn{
            margin-left: 42px;
        }
    }
    .two_form{
        display: block;
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        .two_form_item{
            width: 1190px;
        }
        .two_form_item_a{
            width: 90px;
        }
    }
    .picker{
        height: 30px;
    }
  }

</style>